﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ECONTACT.Bussiness;
using ECONTACT.DataLayer;
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar.Controls;
using DevComponents.Editors.DateTimeAdv;

namespace ECONTACT.Controller
{
    public class KhoiLopCtrl
    {
        KhoiLopData m_KhoiLopData = new KhoiLopData();

        #region Hien thi ComboBox
        public void HienThiComboBox(ComboBoxEx comboBox)
        {
            comboBox.DataSource = m_KhoiLopData.LayDsKhoiLop();
            comboBox.DisplayMember = "MaKhoi";
            comboBox.ValueMember = "MaKhoi";
        }
        public void HienThiComboBoxTen(ComboBoxEx comboBox)
        {
            comboBox.DataSource = m_KhoiLopData.LayDsKhoiLop();
            comboBox.DisplayMember = "TenKhoi";
            comboBox.ValueMember = "MaKhoi";
        }
        #endregion

        #region Do du lieu vao DataGridView
        public void HienThi(DataGridViewX dGV,
                            TextBoxX txtMaKL,
                            TextBoxX txtTenKL)
        {
            BindingSource bS = new BindingSource();
            bS.DataSource = m_KhoiLopData.LayDsKhoiLop();

            DataTable dT = m_KhoiLopData.LayDsKhoiLop();

            txtMaKL.DataBindings.Clear();
            txtMaKL.DataBindings.Add("Text", bS, "MaKhoi");

            txtTenKL.DataBindings.Clear();
            txtTenKL.DataBindings.Add("Text", bS, "TenKhoi");

            //bN.BindingSource = bS;
            dGV.DataSource = bS;
        }
        #endregion

        public void LuuKhoiLop(String Ten)
        {
            m_KhoiLopData.LuuKhoiLop(Ten);
        }

        public void UpdateKhoiLop(String MaKhoi, String Ten)
        {
            m_KhoiLopData.UpdateKhoiLop(MaKhoi, Ten);
        }

        public void DeleteKhoiLop(String MaKhoi)
        {
            m_KhoiLopData.DeleteKhoiLop(MaKhoi);
        }
    }
}
